/* *
 * 常世超(作者)
 * 2018-02-24(开始日期)
 * 2018-03-12(最终更改日期)
 * 常世超(最后更改者)
 * */

//从地址栏获取参数
var urlstatus = globalFun.GetQueryString('status')
// var uuid = globalFun.GetQueryString('uuid')
// var phone = globalFun.GetQueryString('phone')
// if(urlstatus){
// 		tips(urlstatus)
// }
	// localStorage.setItem('orderStatus',urlstatus)
// var zhuangtai = localStorage.getItem('orderStatus')

var initialize = true;
//传参对象---------usertype:0--会员，1---猎头
if(Auth()) {
		uuid= user_info.uuid;
		phone= user_info.phone;
}else{
	if (mark===1) {
 setupWebViewJavascriptBridge(function(bridge){
     bridge.callHandler('jsToClientLogin',type,function(resp){});
 });
	} else if (mark===0) {
	    window.stub.jsToClientLogin();
	}
}
	var dataObj = {
		status: urlstatus,
		userType: 0,
		page: 1,
		rows: 10,
		uuid:uuid,
		phone:phone
	}
	if(urlstatus == 0) {
	$('#daifukuan').addClass('aaa')
	$('#daifukuan').siblings().removeClass('aaa')
	dataObj.status = 0
	 shuju(1, 10, false)
	} else if(urlstatus == 2) {
		$('#daifahuo').addClass('aaa')
		$('#daifahuo').siblings().removeClass('aaa')
		dataObj.status = 2
		 shuju(1, 10, false)
	} else if(urlstatus == 3) {
		$('#daishouhuo').addClass('aaa')
		$('#daishouhuo').siblings().removeClass('aaa')
		dataObj.status = 3
		 shuju(1, 10, false)
	} else if(urlstatus == 7) {
		$('#daipingjia').addClass('aaa')
		$('#daipingjia').siblings().removeClass('aaa')
		dataObj.status = 7
		 shuju(1, 10, false)
	}else if(urlstatus == 8){
		$('#all_order').addClass('aaa')
		$('#all_order').siblings().removeClass('aaa')
		dataObj.status = 8
		 shuju(1, 10, false)
	}


//获取全部订单
function shuju(page, rows, zhuiJia, chengGong, shiBai) {

	if(!zhuiJia) {
		initialize = true;
	}
	if(page) {
		dataObj.page = page;
		dataObj.rows = rows;
	}
	$.ajax({
		type: "POST",
		url: apicom + "mobile/after/order/queryOnlineOrders",
		data: dataObj,
		async:false,
		success: function(res) {
			if(typeof(res) == "String") {
				var dataContent = JSON.parse(res);
			} else {
				var dataContent = res
			}
			if(dataContent.code == 1) {
				var data = dataContent.content
				if(chengGong) {
					chengGong(data)
				}
				console.log(data)
				var ss = ''
				if(data.length == 0) {
					ss += "<div class='order_kong'><img src='../../img/b_oeder_kong.png'/></div>";
					if(!zhuiJia) {
						$('#all_order_xq').html(ss);
					}
				} else {
					for(var i = 0; i < data.length; i++) {
					// if(data[i].nickName==null||data[i].nickName==''||data[i].nickName=="undefined"){
						ss += "<div class='all_order' shouhou-is="+data[i].isAftermarket+" zhifu-zj="+data[i].total_price +" zhifu-time=" + data[i].createTime+" data-id=" + data[i].orderNo +" shouhou-id=" + data[i].id + " lietou-id="+data[i].merchantId +" lietou-img="+data[i].mechantImg+" lietou-name="+data[i].nickName+ " lietou-uu=" + data[i].merchantUuid + " pt-uu="+data[i].serverUuid+" pt-name="+data[i].serverNickName+" pt-img="+data[i].serverImg+"><div class='shop_1'><div class='shop_left'>"
					// }else{
					// 	ss += "<div class='all_order' data-id=" + data[i].orderNo +" shouhou-id=" + data[i].id + " lietou-id="+data[i].merchantId +" lietou-img="+data[i].mechantImg+" lietou-name="+data[i].nickName+" lietou-uu=" + data[i].merchantUuid + "><div class='shop_1'><div class='shop_left'>"
					// }
					if(data[i].merchantId==null){
						ss+="<img class='shop_logo' src='../../img/b_dianpumoren.png'/><p class='shop_name'>平台</p><img class='shop_go' src='../../img/b_03_03.png'/></div>"
					}else{
						if(data[i].mechantImg==null){
							ss+="<img class='shop_logo' src='../../img/b_moren3x.png'/><p class='shop_name'>" + data[i].nickName + "</p><img class='shop_go' src='../../img/b_03_03.png'/></div>"
						}else{
							ss+="<img class='shop_logo' src='" + data[i].mechantImg + "'/><p class='shop_name'>" + data[i].nickName + "</p><img class='shop_go' src='../../img/b_03_03.png'/></div>"
						}
					}
						if(data[i].status == 0) {
							ss += "<p class='order_status1'>等待付款</p></div>"
						}
						if(data[i].status == 2) {
							ss += "<p class='order_status2'>等待发货</p></div>"
						}
						if(data[i].status == 3) {
							ss += "<p class='order_status3'>等待收货</p></div>"
						}
						if(data[i].status == 6) {
							ss += "<p class='order_status4'>交易关闭</p></div>"
						}
						if(data[i].status == 7 || data[i].status == 4) {
							ss += "<p class='order_status5'>交易成功</p></div>"
						}

						for(var j = 0; j < data[i].son.length; j++) {
							//判断订单状态
							//待付款状态
							if(data[i].status == 0) {
								ss += "<div class='shop_thing' data-status=" + data[i].son[j].status + " dingdan-id=" + data[i].son[j].id + " product-id=" + data[i].son[j].pId + "><div class='thing_img'><img src='" + data[i].son[j].address + "'/></div><dl class='thing_xq'><dt class='thing_title'>" + data[i].son[j].name + "</dt><dd class='thing_guige'>" + data[i].son[j].productSpecificationName + "</dd></dl><div class='thing_shuliang'><p class='thing_danjia'>¥" + data[i].son[j].sPrice + "</p><p class='thing_num'>×" + data[i].son[j].num + "</p></div></div>"
							}
							//待发货状态
							if(data[i].status == 2) {
								ss += "<div class='shop_thing' data-status=" + data[i].son[j].status + " dingdan-id=" + data[i].son[j].id + "product-id=" + data[i].son[j].pId + "><div class='thing_img'><img src='" + data[i].son[j].address + "'/></div><dl class='thing_xq'><dt class='thing_title'>" + data[i].son[j].name + "</dt><dd class='thing_guige'>" + data[i].son[j].productSpecificationName + "</dd></dl><div class='thing_shuliang'><p class='thing_danjia'>¥" + data[i].son[j].sPrice + "</p><p class='thing_num'>×" + data[i].son[j].num + "</p></div></div>"
							}
							//待收货状态
							if(data[i].status == 3) {
								ss += "<div class='shop_thing' data-status=" + data[i].son[j].status + " dingdan-id=" + data[i].son[j].id + "product-id=" + data[i].son[j].pId + "><div class='thing_img'><img src='" + data[i].son[j].address + "'/></div><dl class='thing_xq'><dt class='thing_title'>" + data[i].son[j].name + "</dt><dd class='thing_guige'>" + data[i].son[j].productSpecificationName + "</dd></dl><div class='thing_shuliang'><p class='thing_danjia'>¥" + data[i].son[j].sPrice + "</p><p class='thing_num'>×" + data[i].son[j].num + "</p></div></div>"
							}
							if(data[i].status == 6) {
								ss += "<div class='shop_thing' data-status=" + data[i].son[j].status + " dingdan-id=" + data[i].son[j].id + "product-id=" + data[i].son[j].pId + "><div class='thing_img'><img src='" + data[i].son[j].address + "'/></div><dl class='thing_xq'><dt class='thing_title'>" + data[i].son[j].name + "</dt><dd class='thing_guige'>" + data[i].son[j].productSpecificationName + "</dd></dl><div class='thing_shuliang'><p class='thing_danjia'>¥" + data[i].son[j].sPrice + "</p><p class='thing_num'>×" + data[i].son[j].num + "</p></div></div>"
							}
							//待评价状态
							if(data[i].status == 4) {
								ss += "<div class='shop_thing' data-status=" + data[i].son[j].status + " dingdan-id=" + data[i].son[j].id + "product-id=" + data[i].son[j].pId + "><div class='thing_img'><img src='" + data[i].son[j].address + "'/></div><dl class='thing_xq'><dt class='thing_title'>" + data[i].son[j].name + "</dt><dd class='thing_guige'>" + data[i].son[j].productSpecificationName + "</dd></dl><div class='thing_shuliang'><p class='thing_danjia'>¥" + data[i].son[j].sPrice + "</p><p class='thing_num'>×" + data[i].son[j].num + "</p></div></div>"
							}
							if(data[i].status == 7) {
								ss += "<div class='shop_thing' data-status=" + data[i].son[j].status + " dingdan-id=" + data[i].son[j].id + "product-id=" + data[i].son[j].pId + "><div class='thing_img'><img src='" + data[i].son[j].address + "'/></div><dl class='thing_xq'><dt class='thing_title'>" + data[i].son[j].name + "</dt><dd class='thing_guige'>" + data[i].son[j].productSpecificationName + "</dd></dl><div class='thing_shuliang'><p class='thing_danjia'>¥" + data[i].son[j].sPrice + "</p><p class='thing_num'>×" + data[i].son[j].num + "</p></div></div>"
							}
						}
						if(data[i].merchantId==null){
						if(data[i].status == 0) {
							ss += "<div class='shop_sum'><p>应付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='lijifukuan'>立即付款</p><p class='lianxilietou'>联系团队</p></div></div>"
						}
						if(data[i].status == 2) {
							ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='lianxilietou'>联系团队</p></div></div>"
						}
						if(data[i].status == 3) {
							ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='querenshouhuo'>确认收货</p><p class='lianxilietou'>联系团队</p></div></div>"
						}
						if(data[i].status == 6) {
							ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='order_delete'>删除订单</p></div></div>"
						}
						if(data[i].status == 4) {
							if(data[i].isAftermarket==1){
								ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='chakanpingjia'>查看评价</p><p class='shenqingshouhou'>申请售后</p><p class='order_delete'>删除订单</p><p class='lianxilietou'>联系团队</p></div></div>"
							}else if(data[i].isAftermarket==0){
								ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span 	class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='chakanpingjia'>查看评价</p><p class='order_delete'>删除订单</p><p class='lianxilietou'>联系团队</p></div></div>"

							}
						}
						if(data[i].status == 7) {
							if(data[i].isAftermarket==1){
								ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='chakanpingjia'>评价商品</p><p class='shenqingshouhou'>申请售后</p><p class='order_delete'>删除订单</p><p class='lianxilietou'>联系团队</p></div></div>"
							}else if(data[i].isAftermarket==0){
								ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span 	class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='chakanpingjia'>评价商品</p><p class='order_delete'>删除订单</p><p class='lianxilietou'>联系团队</p></div></div>"

							}
						}
						}else{
						if(data[i].status == 0) {
							ss += "<div class='shop_sum'><p>应付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='lijifukuan'>立即付款</p><p class='lianxilietou'>联系团队</p></div></div>"
						}
						if(data[i].status == 2) {
							ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='lianxilietou'>联系团队</p></div></div>"
						}
						if(data[i].status == 3) {
							ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='querenshouhuo'>确认收货</p><p class='lianxilietou'>联系团队</p></div></div>"
						}
						if(data[i].status == 6) {
							ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='order_delete'>删除订单</p></div></div>"
						}
						if(data[i].status == 4) {
							if(data[i].isAftermarket==1){
								ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='chakanpingjia'>查看评价</p><p class='shenqingshouhou'>申请售后</p><p class='order_delete'>删除订单</p><p class='lianxilietou'>联系团队</p></div></div>"
							}else if(data[i].isAftermarket==0){
								ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span 	class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='chakanpingjia'>查看评价</p><p class='order_delete'>删除订单</p><p class='lianxilietou'>联系团队</p></div></div>"

							}
						}
						if(data[i].status == 7) {
							if(data[i].isAftermarket==1){
								ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='chakanpingjia'>评价商品</p><p class='shenqingshouhou'>申请售后</p><p class='order_delete'>删除订单</p><p class='lianxilietou'>联系团队</p></div></div>"
							}else if(data[i].isAftermarket==0){
								ss += "<div class='shop_sum'><p>已付金额 :<span class='zongji'>¥" + data[i].total_price + "</span><span 	class='yunfei'>( 运费" + data[i].productFreight + "元 )</span></p></div><div class='order_caozuo'><p class='chakanpingjia'>评价商品</p><p class='order_delete'>删除订单</p><p class='lianxilietou'>联系团队</p></div></div>"

							}
						}

					}

					if(!zhuiJia) {
						$('#all_order_xq').html(ss)
					} else if(zhuiJia == true) {
						$('#all_order_xq').append(ss)
					}

				}
			}
		}
		},
		error: function(err) {
			console.log(err)
		}
	})
}
shuju(1, 10, false)
//zzz()
//点击切换订单状态
//全部订单
$('#all_order').on('click', function() {
	$('#all_order_xq').html("")
	$(this).addClass('aaa')
	$(this).siblings().removeClass('aaa')
	dataObj.status = 8
	// localStorage.setItem('orderStatus', "8")
	window.location.href = rootdomain+"html/order/my_order.html?status=8"
//	location.reload()
	// shuju(1, 10, false)
	//			zzz()
})
//等待付款
$('#daifukuan').on('click', function() {
	$('#all_order_xq').html("")
	$(this).addClass('aaa')
	$(this).siblings().removeClass('aaa')
	dataObj.status = 0
	// localStorage.setItem('orderStatus', "0")
	window.location.href = rootdomain+"html/order/my_order.html?status=0"
//	location.reload()
	// shuju(1, 10, false)
	//			zzz()
})
//等待发货
$('#daifahuo').on('click', function() {
	$('#all_order_xq').html("")
	$(this).addClass('aaa')
	$(this).siblings().removeClass('aaa')
	dataObj.status = 2
	// localStorage.setItem('orderStatus', "2")
	window.location.href = rootdomain+"html/order/my_order.html?status=2"
//	location.reload()
	// shuju(1, 10, false)
	//			zzz()
})
//等待收货
$('#daishouhuo').on('click', function() {
	$('#all_order_xq').html("")
	$(this).addClass('aaa')
	$(this).siblings().removeClass('aaa')
	dataObj.status = 3
	// localStorage.setItem('orderStatus', "3")
	window.location.href = rootdomain+"html/order/my_order.html?status=3"
//	location.reload()
	// shuju(1, 10, false)
	//			zzz()
})
//等待评价
$('#daipingjia').on('click', function() {
	$('#all_order_xq').html("")
	$(this).addClass('aaa')
	$(this).siblings().removeClass('aaa')
	dataObj.status = 7
	// localStorage.setItem('orderStatus', "7")
	window.location.href = rootdomain+"html/order/my_order.html?status=7"
//	location.reload()
	// shuju(1, 10, false)
	//			zzz()
})

//点击跳转订单详情
$('#all_order_xq').on('click', '.shop_thing', function() {
	//			console.log(1)
	localStorage.setItem('orderNo', $(this).parents('.all_order').attr('data-id'))
	localStorage.setItem('merchantImg', $(this).parents('.all_order').attr('lietou-img'))
	localStorage.setItem('nickName',  $(this).parents('.all_order').attr('lietou-name'))
	localStorage.setItem('isshouhou',  $(this).parents('.all_order').attr('shouhou-is'))
//	localStorage.setItem('orderStatus', $(this).attr('data-status'))
	//订单详情----等待付款
	if($(this).attr('data-status') == 0) {
		window.location.href = rootdomain+"html/order/order_details_ddfk.html"
	}
	//订单详情----等待发货
	if($(this).attr('data-status') == 2) {
		window.location.href = rootdomain+"html/order/order_details_ddfh.html"
	}
	//订单详情----等待收货
	if($(this).attr('data-status') == 3) {
		window.location.href = rootdomain+"html/order/order_details_ddsh.html"
	}
	//订单详情----交易关闭
	if($(this).attr('data-status') == 6) {
		window.location.href = rootdomain+"html/order/order_details_jygb.html"
	}
	//订单详情----交易成功
	if($(this).attr('data-status') == 7 || $(this).attr('data-status') == 4) {
		window.location.href = rootdomain+"html/order/order_details_jywc.html"
	}
})

//删除订单
if(Auth()) {
	var deleteObj = {
		//			phone: 15011552665,
		phone: user_info.phone,
		//			uuid: "09d34ce877a14ce7a5411c6529b99484",
		uuid: user_info.uuid,
		type: 1 //会员
	}
}

$('#all_order_xq').on('click', '.order_delete', function() {
	var that = $(this)
	console.log(1)
	var orderNo = $(this).parents('.all_order').attr('data-id')
	deleteObj.orderNo = orderNo;
	console.log(orderNo)
	$.ajax({
		type: "POST",
		url: apicom + "mobile/after/order/deleteOrderByMember",
		data: deleteObj,
		success: function(res) {
			if(typeof(res) == "String") {
				var data1 = JSON.parse(res);
			} else {
				var data1 = res
			}
			if(data1.code == 1) {

				that.parent().parent().remove();
				tips('删除成功');
			} else {
				tips('订单不存在或已经删除，请刷新重试');
			}
		},
		error: function(err) {
			console.log(err)
		}
	})
})
//取消订单
//	var quxiaoObj = {
//			uuid: "09d34ce877a14ce7a5411c6529b99484",
//			phone: 15011552665,
//		}
//	$('#all_order_xq').on('click','.quxiaodingdan',function(){
//		console.log(1)
//		var orderId = $(this).parents('.all_order').attr('data-id')
//		deleteObj.oids = orderId ;
//		console.log(orderId)
//		$.ajax({
//			type: "POST",
//			url: "http://192.168.30.249:10001/mobile/after/order/cancelOrder",
//			data: deleteObj,
//			success:function(res){
//				var data1 = JSON.parse(res);
////				console.log(data1)
//				if(res.code==1){
//					$(this).parents('.all_order').remove();
//					tips(res.msg);
//				}
//			},
//			error:function(err){
////				var data1 = JSON.parse(err);
//				tips(data1.msg);
//			}
//		})
//	})
//返回
$('.back').on('click', function() {	
	 // if (globalFun.GetQueryString('from') == 'app') {
	 // 	window.location.href = rootdomain + "html/order/my_order.html"
	 // } else if(globalFun.GetQueryString('from') == 'zxx'){
	 // 	sessionStorage.setItem('currentUrl',rootdomain + "html/singlecenter/gerencenter_login.html")
	 // 	window.location.href = rootdomain + "html/homePage/sy.html"
	 // }else{
	 // 	window.history.go(-1)
	 // }
	houTui()
})
//立即付款
$('#all_order_xq').on('click', '.lijifukuan', function() {
	var fk = [];
	var ffkk = '';
	var zongjia;
	var creatTime;
	fukuan = $(this).parents(".all_order").children('.shop_thing');
	zongjia = $(this).parents(".all_order").attr('zhifu-zj');
	creatTime = $(this).parents(".all_order").attr('zhifu-time')
	var orderNo = $(this).parents('.all_order').attr('data-id')
	console.log(fk)
	for(var i = 0; i < fukuan.length; i++) {

		//				console.log(fukuan[i].attr('dingdan-id')/1)
		fk.push(fukuan[i].getAttribute('dingdan-id') / 1)
	}
	if(fk.length == 1) {
		ffkk = fk.join()
	} else if(fk.length > 1) {
		ffkk = fk.join(',')
	}
	localStorage.setItem("createdTime",creatTime)
	localStorage.setItem("orderTotalPrice",zongjia)
	window.location.href = rootdomain + "html/product-order/payment.html?orderIds=" + orderNo +"&orderType=1";
})

//查看评价---33
$('#all_order_xq').on('click', '.chakanpingjia', function() {
	var lx = $(this).parents('.all_order').attr('data-id')
	var lt = $(this).parents('.all_order').attr('lietou-id')
	var ptimg = $(this).parents('.all_order').attr('pt-img')
	var ptuu = $(this).parents('.all_order').attr('pt-uu')
	var ptnicheng = $(this).parents('.all_order').attr('pt-name')
	var merchantImg = $(this).parents('.all_order').attr('lietou-img')
	var ltuu = $(this).parents('.all_order').attr('lietou-uu')
	console.log(lt)
//	console.log(merchantImg)
	var ltnicheng = $(this).parents('.all_order').attr('lietou-name')
	var datalianxi = {
			orderNo: lx,
			phone: user_info.phone,
			uuid: user_info.uuid,//用户的uuid
			merchantId:lt,
			data: '33' //联系猎头
		}
//	console.log(ltnicheng)
	if(lt=="null"){
		datalianxi.userId = ptuu;
		datalianxi.Img = ptimg;
		datalianxi.nickName =  ptnicheng
	}else{
		datalianxi.userId = ltuu;
		datalianxi.Img = merchantImg;
		datalianxi.nickName =  ltnicheng
	}
	// var jiaoHu = JSON.stringify(datalianxi)
	// console.log(jiaoHu)
	TiaoZhuan(datalianxi)
})
//确认收货
$('#all_order_xq').on('click', '.querenshouhuo', function() {
					// tips("收货成功")
	var that = $(this)
	var qr = $(this).parents('.all_order').attr('data-id')

	if(Auth()) {
		var queRen = {
			phone:user_info.phone,
			orderNo: qr,
			uuid: user_info.uuid
		}
	}
	console.log(queRen)
	$.ajax({
		type: "post",
		url: apicom + "mobile/after/orderPlace/confirmReceive",
		data: queRen,
		success: function(res) {
			if(typeof(res) == "String") {
				var data3 = JSON.parse(res);
			} else {
				var data3 = res
			}
			console.log(data3)
			if(data3.code == 1) {
				that.parent().parent().remove();
				tips("收货成功")
				// localStorage.setItem("orderStatus",3)
				// location.reload()

			}
		},
		error: function(err) {
			console.log(err)
		}
	});
})
//申请售后    30
$('#all_order_xq').on('click', '.shenqingshouhou', function() {
	var lx = $(this).parents('.all_order').attr('data-id')
	var lt = $(this).parents('.all_order').attr('lietou-id')
	var ptimg = $(this).parents('.all_order').attr('pt-img')
	var ptuu = $(this).parents('.all_order').attr('pt-uu')
	var ptnicheng = $(this).parents('.all_order').attr('pt-name')
	var merchantImg = $(this).parents('.all_order').attr('lietou-img')
	var ltuu = $(this).parents('.all_order').attr('lietou-uu')
	console.log(ltuu)
//	console.log(merchantImg)
	var ltnicheng = $(this).parents('.all_order').attr('lietou-name')
	var datalianxi = {
			orderNo: lx,
			phone: user_info.phone,
			uuid: user_info.uuid,//用户的uuid
			merchantId:lt,
			data: '30' //联系猎头
		}
//	console.log(ltnicheng)
	if(lt=="null"){
		datalianxi.userId = ptuu;
		datalianxi.Img = ptimg;
		datalianxi.nickName =  ptnicheng
	}else{
		datalianxi.userId = ltuu;
		datalianxi.Img = merchantImg;
		datalianxi.nickName =  ltnicheng
	}
	// var jiaoHu = JSON.stringify(datalianxi)
	// console.log(jiaoHu)
	TiaoZhuan(datalianxi)
})

//评价商品    31
$('#all_order_xq').on('click', '.pingjiashangpin', function() {
	var lx = $(this).parents('.all_order').attr('data-id')
	var lt = $(this).parents('.all_order').attr('lietou-id')
	var ptimg = $(this).parents('.all_order').attr('pt-img')
	var ptuu = $(this).parents('.all_order').attr('pt-uu')
	var ptnicheng = $(this).parents('.all_order').attr('pt-name')
	var merchantImg = $(this).parents('.all_order').attr('lietou-img')
	var ltuu = $(this).parents('.all_order').attr('lietou-uu')
	console.log(lt)
//	console.log(merchantImg)
	var ltnicheng = $(this).parents('.all_order').attr('lietou-name')
	var datalianxi = {
			orderNo: lx,
			phone: user_info.phone,
			uuid: user_info.uuid,//用户的uuid
			merchantId:lt,
			data: '31' //联系猎头
		}
//	console.log(ltnicheng)
	if(lt=="null"){
		datalianxi.userId = ptuu;
		datalianxi.Img = ptimg;
		datalianxi.nickName =  ptnicheng
	}else{
		datalianxi.userId = ltuu;
		datalianxi.Img = merchantImg;
		datalianxi.nickName =  ltnicheng
	}
	// var jiaoHu = JSON.stringify(datalianxi)
	// console.log(jiaoHu)
	TiaoZhuan(datalianxi)
})

//联系猎头     32
$('#all_order_xq').on('click', '.lianxilietou', function() {
	var lx = $(this).parents('.all_order').attr('data-id')
	var lt = $(this).parents('.all_order').attr('lietou-id')
	var ptimg = $(this).parents('.all_order').attr('pt-img')
	var ptuu = $(this).parents('.all_order').attr('pt-uu')
	var ptnicheng = $(this).parents('.all_order').attr('pt-name')
	var merchantImg = $(this).parents('.all_order').attr('lietou-img')
	var ltuu = $(this).parents('.all_order').attr('lietou-uu')
	console.log(lt)
//	console.log(merchantImg)
	var ltnicheng = $(this).parents('.all_order').attr('lietou-name')
	var datalianxi = {
			orderNo: lx,
			phone: user_info.phone,
			uuid: user_info.uuid,//用户的uuid
			merchantId:lt,
			data: '32' //联系猎头
		}
//	console.log(ltnicheng)
	if(lt=="null"){
		datalianxi.userId = ptuu;
		datalianxi.Img = ptimg;
		datalianxi.nickName =  ptnicheng
	}else{
		datalianxi.userId = ltuu;
		datalianxi.Img = merchantImg;
		datalianxi.nickName =  ltnicheng
	}
	// console.log(datalianxi)
	// var jiaoHu = JSON.stringify(datalianxi)
	// console.log(jiaoHu)
	TiaoZhuan(datalianxi)
})
//评价完成的商品，点击返回跳转全部订单页面
 if (mark==1) {
         setupWebViewJavascriptBridge(function(bridge){
           bridge.registerHandler('pingjiaSuccess',function(data,resp){
           			location.reload()
           })
         })
       } else if(mark==0) {
       		function pingjiaSuccess(){
           			location.reload()
       		}
       }
// 点击返回按钮
function houTui() {
	var ua = navigator.userAgent.toLowerCase();
	if(/pjyc_i/.test(ua)) {
		setupWebViewJavascriptBridge(function(bridge) {
			bridge.callHandler('goBack', function(resp) {});
		});
//		if (globalFun.GetQueryString('from') == 'app') {
//		 	window.location.href = rootdomain + "html/order/my_order.html"
// 		 } else if(globalFun.GetQueryString('from') == 'zxx'){
// 		 	sessionStorage.setItem('currentUrl',rootdomain + "html/singlecenter/gerencenter_login.html")
//		 	window.location.href = rootdomain + "html/homePage/sy.html"
//		 }else{
//		 	window.history.go(-1)
//		 }
	} else if(/pujiyicheng/.test(ua)) {
		// tips("lalalala")
		//var result = lase;
		window.stub.goBack(); //用接口stub, 通过调用内部类中的方法jsMethod给java传回result。
//		if (globalFun.GetQueryString('from') == 'app') {
//		 	window.location.href = rootdomain + "html/order/my_order.html"
//		 } else if(globalFun.GetQueryString('from') == 'zxx'){
		 	// sessionStorage.setItem('currentUrl',rootdomain + "html/singlecenter/gerencenter_login.html")
//		 	window.location.href = rootdomain + "html/homePage/sy.html"
//		 }else{
//		 	window.history.go(-1)
//		 }
	}
}
// 与原生APP的交互
function TiaoZhuan(data) {
	var ua = navigator.userAgent.toLowerCase();
	if(/pjyc_i/.test(ua)) {
		setupWebViewJavascriptBridge(function(bridge) {
			bridge.callHandler('jsToClientMine', data, function(resp) {});
		});
	} else if(/pujiyicheng/.test(ua)) {
		var data1 = JSON.stringify(data)
		//var result = lase;
		window.stub.jsToClientAfterSale(data1); //用接口stub, 通过调用内部类中的方法jsMethod给java传回result。

	}
}
/* 上拉加载 */
$(function(){
	//创建MeScroll对象
	var mescroll = initMeScroll("sljz", {
		down: {
			auto: false, //是否在初始化完毕之后自动执行下拉回调callback; 默认true
			callback: downCallback, //下拉刷新的回调
		},
		up: {
			auto: false, //初始化完毕,是否自动触发上拉加载的回调
			isBoth: false, //上拉加载时,如果滑动到列表顶部是否可以同时触发下拉刷新;默认false,两者不可同时触发; 这里为了演示改为true,不必等列表加载完毕才可下拉;
			callback: upCallback, //上拉加载的回调
		}
	});

	function downCallback() {
		//联网加载数据

		shuju(1, 10, false, function(data) {
			mescroll.endSuccess(data.length); //传参:数据的总数; mescroll会自动判断列表如果无任何数据,则提示空;列表无下一页数据,则提示无更多数据;
			//设置列表数据
		}, function() {
			mescroll.endErr();
		})
	}

	function upCallback(page) {
		if(initialize == true) {
			initialize = false;
			page.num = 2
		}
		//联网加载数据
		shuju(page.num, page.size, true, function(data) {
			mescroll.endSuccess(data.length); //传参:数据的总数; mescroll会自动判断列表如果无任何数据,则提示空;列表无下一页数据,则提示无更多数据;
			//设置列表数据
		}, function() {
			mescroll.endErr();
		})
	}

	//禁止PC浏览器拖拽图片,避免与下拉刷新冲突;如果仅在移动端使用,可删除此代码
	document.ondragstart = function() {
		return false;
	}
});